// uni.request 的二次封装
// 以对象形式传参

function http({
	url,
	data = {},
	method
}) {
	// 基础地址
	let baseUrl = "https://api.it120.cc/xiaochengxu"
	if(uni.getStorageSync("token")){
		data["token"] = uni.getStorageSync("token")
	}
	return new Promise((resolve, reject) => {
		uni.request({
			url: baseUrl + url,
			data,
			method,
			header: {
				"content-type": "application/x-www-form-urlencoded"
			},
			timeout: 3000,
			success: res => {
				resolve(res.data)
			},
			fail: err => {
				reject(err)
			}
		})
	})
}
export default http
